package com.ruoyi.statistics.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistics.domain.LabStatisticsLaboratory;
import com.ruoyi.statistics.service.ILabStatisticsLaboratoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实验室基本情况Controller
 * 
 * @author jun.wang
 * @date 2022-05-21
 */
@RestController
@RequestMapping("/statistics/laboratory")
public class LabStatisticsLaboratoryController extends BaseController
{
    @Autowired
    private ILabStatisticsLaboratoryService labStatisticsLaboratoryService;

    /**
     * 查询实验室基本情况列表
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsLaboratory:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabStatisticsLaboratory labStatisticsLaboratory)
    {
        startPage();
        List<LabStatisticsLaboratory> list = labStatisticsLaboratoryService.selectLabStatisticsLaboratoryList(labStatisticsLaboratory);
        return getDataTable(list);
    }

    /**
     * 导出实验室基本情况列表
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsLaboratory:export')")
    @Log(title = "实验室基本情况", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabStatisticsLaboratory labStatisticsLaboratory)
    {
        List<LabStatisticsLaboratory> list = labStatisticsLaboratoryService.selectLabStatisticsLaboratoryList(labStatisticsLaboratory);
        ExcelUtil<LabStatisticsLaboratory> util = new ExcelUtil<LabStatisticsLaboratory>(LabStatisticsLaboratory.class);
        return util.exportExcel(list, "statisticsLaboratory");
    }

    /**
     * 获取实验室基本情况详细信息
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsLaboratory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(labStatisticsLaboratoryService.selectLabStatisticsLaboratoryById(id));
    }

    /**
     * 新增实验室基本情况
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsLaboratory:add')")
    @Log(title = "实验室基本情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabStatisticsLaboratory labStatisticsLaboratory)
    {
        return toAjax(labStatisticsLaboratoryService.insertLabStatisticsLaboratory(labStatisticsLaboratory));
    }

    /**
     * 修改实验室基本情况
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsLaboratory:edit')")
    @Log(title = "实验室基本情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabStatisticsLaboratory labStatisticsLaboratory)
    {
        return toAjax(labStatisticsLaboratoryService.updateLabStatisticsLaboratory(labStatisticsLaboratory));
    }

    /**
     * 删除实验室基本情况
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsLaboratory:remove')")
    @Log(title = "实验室基本情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(labStatisticsLaboratoryService.deleteLabStatisticsLaboratoryByIds(ids));
    }
}
